<?php

require_once 'config.php';
require_once 'incs/database.php';

if (!dataBase::connect(
        config::HOST,
        config::USERNAME,
        config::PASSWORD,
        config::NAME
    )) {
    echo "Failed to connect.";
    die();
}

$db = dataBase::getInstance();

$salt = substr(md5(uniqid()), 0, 12);

$userName = "test3@test.com";
$pass = "F0407203";
$len = strlen($pass);

$pass = md5($pass);
$div = intval(32 / $len);
$pass = md5(substr($pass, 0, $div)
        . $salt
        . substr($pass, $div));

$db->insert('users', array(
    'username' => $userName,
    'password' => $pass,
    'salt' => $salt,
));

$id = mysql_insert_id();
?>
<table>
    <tr>
        <td> </td>
        <td>Column 1</td>
        <td>Column 2</td>
        <td>Column 3</td>
        <td>Column 4</td>
    </tr>
<?php
for ($i = 1; $i < 7; $i++) :
?>
    <tr>
        <td>Row <?php echo $i; ?></td>
<?php
    for ($j = 0; $j < 5; $j++) :
        if ($j === 0)
            continue;

        $tanVal = rand(1000000, 9999999);
        $db->insert('tan_tables', array(
            'user_id' => $id,
            'row' => $j,
            'column' => $i,
            'value' => md5($tanVal),
        ));

?>
        <td><?php echo $tanVal; ?></td>
<?php
    endfor;
?>
    </tr>
<?php
endfor;
?>
</table>
